import _extends from 'babel-runtime/helpers/extends';
import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
import _createClass from 'babel-runtime/helpers/createClass';
import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn';
import _inherits from 'babel-runtime/helpers/inherits';
/**
 * 带权限校验的Table组件，兼容antd.Table
 * @Author: lisy
 * @Date: 2018-11-28 14:49:05
 */
import * as React from 'react';
import { Table } from 'antd';

var TableAuth = function (_React$Component) {
    _inherits(TableAuth, _React$Component);

    function TableAuth() {
        _classCallCheck(this, TableAuth);

        var _this = _possibleConstructorReturn(this, (TableAuth.__proto__ || Object.getPrototypeOf(TableAuth)).apply(this, arguments));

        _this.getTable = function () {
            var columnsList = _this.props.columns;
            if (_this.props.check) {
                var allAuths = JSON.parse(sessionStorage.allAuths);
                columnsList = columnsList.filter(function (item) {
                    return allAuths.includes(item.key);
                });
            }
            return React.createElement(Table, _extends({}, _this.props, { columns: columnsList }));
        };
        return _this;
    }

    _createClass(TableAuth, [{
        key: 'render',
        value: function render() {
            return this.getTable();
        }
    }]);

    return TableAuth;
}(React.Component);

export default TableAuth;